<template>
	<div class="school-list">
		<HeadCustom></HeadCustom>
		<view class="search">
			<u-search placeholder="请输入学校名称" @custom="search" v-model="schoolParms.schoolName" @change="search"></u-search>
		</view>
		<!-- <view class="select">
			<u-dropdown>
				<u-dropdown-item title="属性">
					
				</u-dropdown-item>
			</u-dropdown>
		</view> -->
		<view class="list-item">
			<schoolItem v-for="(item,index) in schooList" :key="item.id" :detail="item"></schoolItem>
		</view>
		<u-loadmore :status="status" />
	</div>
</template>

<script>
	import schoolItem from '@/schoolMsg/components/school-item.vue'
	import {
		getSchoolList
	} from '@/utils/api.js'
	export default {
		components: {
			schoolItem
		},
		props: {

		},
		onShow() {
			if(this.schooList.length === 0) {
				this.getList()
			}
			
		},
		data() {
			return {	
				schoolParms:{
					pageNum:1,
					pageSize:20,
					schoolName:''
				},
				status:'loading',
				schooList:[],
			};
		},
		methods: {
			golist() {
				uni.navigateTo({
					// url:'schoolMsg/'
					url: '/schoolMsg/schoolList/index'
				})
			},
			async getList() {
				let res = await getSchoolList(this.schoolParms)
				if(res.code == 200) {
					this.schooList = this.schooList.concat(res.rows)
				}
				if(res.rows.length < 20) {
					this.status = 'nomore';
				}else {
					this.status = 'loadmore';
				}
				
			},
			async search() {
				this.schooList = []
				this.schoolParms.pageNum = 1
				this.getList()
			},
			closeDropdown() {
				this.$refs.uDropdown.close();
			}
		},
		onReachBottom() {
			this.status = 'loading';
			this.schoolParms.pageNum++
			this.getList()
			
		}
	};
</script>

<style lang="scss" scoped>
	.school-list {
		background-color: #f8f8f8;
		min-height: 100vh;
	}
</style>